using SmartBoard.Book.Model;

namespace SmartBoard.Book.Commands
{
    public class SaveAsBookAction : BookUIActionBase
    {
        public SaveAsBookAction(BookManager bookManager, IBookUIManager bookUIManager) : base(bookManager, bookUIManager)
        { }

        public override void Execute(object parameter)
        {
            var dialog = _bookUIManager.SaveAsBookDialog;
            if (dialog.PresentUI() == true)
            {
                _bookManager.Book.Location = dialog.Location;
            }
            _bookManager.Book.Save(_bookManager.Book.Location);
        }

        public override bool CanExecute(object parameter)
        {
            return _bookManager.Book != null && !string.IsNullOrEmpty(_bookManager.Book.Location);
        }
    }
}